/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.game.room;

import com.smartfoxserver.v2.entities.User;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author daz
 */
public abstract class Player {

    public static final int PLAYING = 2;
    public static final int READY = 1;
    public static final int NOT_READY = 0;
    protected String name;
    protected long money;
    protected long totalMoney;
    protected int seatPos;
    public boolean isHost;
    protected int state;
    protected User user;
    protected List<Integer> listCardIds;
    protected int numberCardInHands;
    protected int rank;
    protected long moneyChange;

    public Player(String name, long money, int seatPos) {
        this.name = name;
        this.money = money;
        this.seatPos = seatPos;
        listCardIds = new LinkedList<Integer>();
    }

    public void setMoney(int money) {
        this.money = money;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSeatPos(int seatPos) {
        this.seatPos = seatPos;
    }

    public long getMoney() {
        return money;
    }

    public String getName() {
        return name;
    }

    public int getSeatPos() {
        return seatPos;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int changeState() {
        state = 1 - state;
        return state;
    }

    public int getState() {
        return state;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public User getUser() {
        return user;
    }

    public abstract void resetCard();

    public List<Integer> getListCardIds() {
        return listCardIds;
    }

    public void updateNumberCardInHand() {
        this.numberCardInHands = listCardIds.size();
    }

    public int getNumberCardInHands() {
        return numberCardInHands;
    }

    public int getRank() {
        return rank;
    }

    private static void printListCardId(int[] listCards) {
        int numberCard = listCards.length;
        for (int i = 0; i < numberCard; i++) {
            System.out.print(listCards[i] + ",");
        }
    }

    private static void swap(int i, int j, int[] listCards) {
        int temp = listCards[j];
        listCards[j] = listCards[i];
        listCards[i] = temp;
    }

    public void setTotalMoney(long totalMoney) {
        this.totalMoney = totalMoney;
    }

    public long getTotalMoney() {
        return totalMoney;
    }

    public void setMoneyChange(long moneyChange) {
        this.moneyChange = moneyChange;
    }

    public long getMoneyChange() {
        return moneyChange;
    }

    public void updateMoneChange() {
        this.money += moneyChange;
    }
}
